#pragma once

#include <services/provider.hpp>
#include <engine/engine.hpp>
#include <engine.ui/Widgets.hpp>

#include "GameState.hpp"




class Game
{
public:

	SHARED(Game);
	void post_create(ptr) {}
	MAKE_SHARED2(Game,Engine::IEngine::ptr, services::provider::ptr);

	Game(Engine::IEngine::ptr engine, services::provider::ptr provider);
	~Game();



	/**
	 * Changes the current gamestate to the given one.
	 */
	void setGameState(asIScriptObject* gameState);

	/**
	 * @returns a pointer to the entity system
	 */
	Engine::Entity::System* entitySystem();



	/**
	 * This method advances both the logic and rendering part of the game.
	 * Once this method finishes, a frame is complete and is shown on the screen.
	 */
	void update();



	/**
	 * Registers the Game Type with the engine.
	 */
	static void declareType(Engine::Script::System::ptr engine);
	static void registerType(Engine::Script::System::ptr engine);

private:

	void dummy();

private:

	Engine::IEngine::ptr               m_engine;

	Engine::Entity::System::ptr        m_entitySystem;

	Engine::Script::System::ptr        m_scriptSystem;
	Engine::Script::ContextPool::ptr   m_contextPool;
	Engine::Script::Module::ptr        m_logicModule;

	logger::stream::ptr                m_logger;

	Engine::Ui::Text::ptr              m_text;
	Engine::Ui::Frame::ptr             m_frame;
	Engine::Ui::Window::ptr            m_window;

	// The currently active gamestate
	boost::optional<GameState>         m_currentGameState;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
